# Contributor: Łukasz Jendrysik <scadu@yandex.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=bison
pkgver=3.7.1
pkgrel=0
pkgdesc="The GNU general-purpose parser generator"
arch="all"
license="GPL-3.0-or-later"
url="https://www.gnu.org/software/bison/bison.html"
makedepends="perl"
depends="m4"
checkdepends="bison flex"
[ -n "$BOOTSTRAP" ] && options="!check"
source="https://ftp.gnu.org/gnu/bison/bison-$pkgver.tar.xz"
subpackages="$pkgname-doc"

build() {
	# builders keep failing when -jN == nproc
	export MAKEFLAGS="$MAKEFLAGS -j$((JOBS<4 ? JOBS : 4))"

	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--datadir=/usr/share \
		--infodir=/usr/share/info \
		--mandir=/usr/share/man
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	rm -rf "$pkgdir"/usr/lib/charset.alias
	rmdir -p "$pkgdir"/usr/lib 2>/dev/null || true
}

sha512sums="9c4097b6ff26e819be14a9d4ef39f6f259c04627cd305e11da8e67897a369b2bba5ce96bf19fa5f6088670e90a9c5bc5c45172f8f482252aeec546b285dd0797  bison-3.7.1.tar.xz"
